function set_gz(smmsi) {
	get_shipname(smmsi);
}

function clearAttLi(id, result){
	var li_id = id.split('_')[1];
	jQuery("#att_li_"+li_id).fadeOut("normal",function(){
		if($("at_ship_"+li_id)){
			jQuery("#at_ship_"+li_id).html('<img src="./template/default/images/guanzhuchuanbo.png" alt="关注船舶" />');
			jQuery("#at_ship_"+li_id).attr('href','cp.php?ac=attention&op=atship&mmsi='+li_id+'&shipname='+$('shipname').value);
			jQuery("#at_ship_"+li_id).attr('title','关注这艘船');
			$('shipcommontsubmit').disabled=true;
		}
	});
	getattlist();
}

function clearShipcommont(){
	$("shipcommont").value = '';
}

function trim(str){ //删除左右两端的空格
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

function local_map(jd, wd, zoom) {
	document.getElementById('silverlightControl').content.silverlightmsg.local_map(jd, wd, zoom); //
	if($("mapframe") != null) { $("mapframe").style.display = 'none'; }
}

function save_view(){
	document.getElementById('silverlightControl').content.silverlightmsg.save_view();
}

var t1;

function get_shipname(smmsi) {
	var ship = document.getElementById('silverlightControl').content.silverlightmsg.get_shipname(smmsi); //
	var shiparr = ship.split(';')[0].split(',');
	var shipname = shiparr[0];
	var shipmmsi = shiparr[1];
	var shipcallsign = shiparr[2];

	if(shipname == ''){
		$('ship_name_kly').innerHTML = shipmmsi;
		$('ship_name_kly_1').innerHTML = shipmmsi;
	}else{
		$('ship_name_kly').innerHTML = shipname;
		$('ship_name_kly_1').innerHTML = shipname;
	}
	$('shipname').value = shipname;
	$('callsign').value = shipcallsign;

	getcommont(shipmmsi);
	window.clearInterval(t1);
	t1 = window.setInterval("getcommont("+shipmmsi+")",10000);
	getatt(shipmmsi);
	//ajaxpostHandle = 0;
}

function search_ship_bymmsi(smmsi) {
	var flag = document.getElementById('silverlightControl').content.silverlightmsg.locate_ship(smmsi);

	if(flag){
		get_shipname(smmsi);
	}/*else{
		if($("chu_info").style.display != 'none'){
			jQuery("#chu_info").slideToggle("slow");
		}
		//$("commont_flag").style.display = 'none';
	}*/
}

function search_ship_byname(searchkey){
	ipp = 1;
	var str;
	var ship_result = document.getElementById('silverlightControl').content.silverlightmsg.search_ship(searchkey.toUpperCase(), ipp); //
	var shiparr = ship_result.split(';')[0].split(',');
	var shipname = shiparr[0];
	var shipmmsi = shiparr[1];
	var shipcallsign = shiparr[2];

	if(shipmmsi > 0){
		get_shipname(shipmmsi);
		//模糊查询的时候将下列注释取消
		/*
		str = trim(shipname);
		var li = '';
		for(i=0;i<ship_arr.length;i++){
			var ship_str = trim(ship_arr[i]);
			if(ship_str!=''){
				var s = ship_str.split(':');
				li += "<li><a href=\"javascript:search_ship_bymmsi('"+s[1]+"');\">"+s[0]+"</a></li>";
			}
		}
		$("result_list_data").innerHTML = li;
		jQuery("#result_list").slideToggle("slow");*/
		
	}/*else{
		if($("chu_info").style.display != 'none'){
			jQuery("#chu_info").slideToggle("slow");
		}
	}*/
}

function search_ship_bycallsign(strhh) {
	var ship_result = document.getElementById('silverlightControl').content.silverlightmsg.search_ship_bycallsign(strhh.toUpperCase());

	if(ship_result.length>0){
		var shiparr = ship_result.split(';')[0].split(',');
		var shipname = shiparr[0];
		var shipmmsi = shiparr[1];
		var shipcallsign = shiparr[2];
		get_shipname(shipmmsi);
	}else{
		var ship_result = document.getElementById('silverlightControl').content.silverlightmsg.search_ship(strhh.toUpperCase(), 1);
		var shiparr = ship_result.split(';')[0].split(',');
		var shipname = shiparr[0];
		var shipmmsi = shiparr[1];
		var shipcallsign = shiparr[2];

		if(shipmmsi > 0){
			get_shipname(shipmmsi);
			/*if(ship_arr.length>0){
				//模糊查询的时候将下列注释取消
				var li = '';
				str = trim(ship_arr[0]);
				for(i=0;i<ship_arr.length;i++){
					var ship_str = trim(ship_arr[i]);
					if(ship_str!=''){
						var s = ship_str.split(':');
						li += "<li><a href=\"javascript:search_ship_bymmsi('"+s[1]+"');\">"+s[0]+"</a></li>";
					}
				}
				$("result_list_data").innerHTML = li;
				jQuery("#result_list").slideToggle("slow");
				
			}*/
		}/*else{
			if($("chu_info").style.display != 'none'){
				jQuery("#chu_info").slideToggle("slow");
			}
		}*/
		//$("commont_flag").style.display = 'none';
	}
}

function getatt(mmsi) {
	var x = new Ajax('XML', 'ajax_wait');
	x.get('space.php?do=findship&view=getatt&mmsi='+mmsi, function(s){
		var pre_mmsi = $('mmsi').value=='0'?'':$('mmsi').value;
		if(s == 'khn'){
			jQuery("#at_ship_"+pre_mmsi).html('<img src="./template/default/images/guanzhuchuanbo.png" alt="关注船舶" />');
			jQuery("#at_ship_"+pre_mmsi).attr('href','cp.php?ac=attention&op=atship&mmsi='+mmsi+'&shipname='+$('shipname').value+'&callsign='+$('callsign').value);
			jQuery("#at_ship_"+pre_mmsi).attr('title','关注这艘船');
			jQuery("#at_ship_"+pre_mmsi).attr('id','at_ship_'+mmsi);
			jQuery("#two_button").show();
			$('shipcommontsubmit').disabled=true;
		}else{
			jQuery("#at_ship_"+pre_mmsi).html('<img src="./template/default/images/excguanzhu.png" alt="取消关注" />');
			jQuery("#at_ship_"+pre_mmsi).attr('href','cp.php?ac=attention&op=atship_cancel&mmsi='+mmsi);
			jQuery("#at_ship_"+pre_mmsi).attr('title','取消关注这艘船');
			jQuery("#at_ship_"+pre_mmsi).attr('id','at_ship_'+mmsi);
			jQuery("#two_button").show();
			$('shipcommontsubmit').disabled=false;
		}
		$('mmsi').value = mmsi;
	});
}

function addatt(id, result){
	var ids = id.split('_');
	getattlist();
	$('shipcommontsubmit').disabled=false;
	jQuery("#at_ship_"+ids[1]).html('<img src="./template/default/images/excguanzhu.png" alt="取消关注" />');
	jQuery("#at_ship_"+ids[1]).attr('href','cp.php?ac=attention&op=atship_cancel&mmsi='+ids[1]);
	jQuery("#at_ship_"+ids[1]).attr('title','取消关注这艘船');
}

function cancelatt(id, result){
	var ids = id.split('_');
	getattlist();
	jQuery("#at_ship_"+ids[1]).html('<img src="./template/default/images/guanzhuchuanbo.png" alt="关注船舶" />');
	jQuery("#at_ship_"+ids[1]).attr('href','cp.php?ac=attention&op=atship&mmsi='+ids[1]+'&shipname='+$('shipname').value+'&callsign='+$('callsign').value);
	jQuery("#at_ship_"+ids[1]).attr('title','关注这艘船');
	$('shipcommontsubmit').disabled=true;
}

function getattlist(){
	var x = new Ajax('XML', 'ajax_wait');
	x.get('space.php?do=findship&view=getattlist', function(s){
		$('y_mb_know_a').innerHTML = s;
	});
}

function getFshipList(flag, uid){
	if($(flag+'_shiplist_'+uid).style.display == 'block'){
		jQuery("#"+flag+"_shiplist_"+uid).slideToggle("slow");
	}else{
		var x = new Ajax('XML', 'ajax_wait');
		x.get('space.php?do=findship&view=getfriendships&fuid='+uid, function(s){
			$(flag+'_shiplist_'+uid).innerHTML = s;
			jQuery("#"+flag+"_shiplist_"+uid).slideToggle("slow");
		});
	}
}

function fship_page(page){
	var x = new Ajax('XML', 'ajax_wait');
	x.get('space.php?do=findship_page&view=getflist&page='+page, function(s){
		$('friend_list').innerHTML = s;
	});
}

function fship_planpage(){
	var trends = $('shiptrends').value;
	var status = $('shipstatus').value;
	var str = "";
	if(trends != -1){
		str += "&trends="+trends;
	}
	if(status != -1){
		str += "&status="+status;
	}
	ajaxget("space.php?do=findship_page&ajaxdiv=shipplan"+str, 'shipplan');
}

function fship_mtagpage(page){
	var x = new Ajax('XML', 'ajax_wait');
	x.get('space.php?do=findship_page&view=getmtaglist&page='+page, function(s){
		$('mtag_list').innerHTML = s;
	});
}

function showtr(trid){

	jQuery("#plantable_tr_"+trid).show("normal");

}

function hidetr(trid){

	jQuery("#plantable_tr_"+trid).hide("normal");

}
/*
jQuery(document).ready(function(){
	
	jQuery("#showshiplist").click(function(){
		if(jQuery("#showshiplist").html()=='打开关注列表'){
			jQuery("#showshiplist").html('关闭关注列表');
		}else{
			jQuery("#showshiplist").html('打开关注列表');
		}
		getattlist();
		if($('mapframe')!= null)
			$('mapframe').style.display = 'none';
		jQuery("#chu_list").slideToggle("slow");
	});

	jQuery("#showshipcommont").click(function(){
		if(jQuery("#showshipcommont").html()=='查看评论'){
			jQuery("#showshipcommont").html('关闭评论');
		}else{
			jQuery("#showshipcommont").html('查看评论');
		}
		if($('mapframe')!= null)
			$('mapframe').style.display = 'none';
		jQuery("#chu_info").slideToggle("slow");
	});
});

function getMorearea(){

	var ajaxframeid = 'mapframe';
	var ajaxframe = $(ajaxframeid);
	if(ajaxframe == null) {
		if (is_ie && !is_opera && is_ie < 9) {
			ajaxframe = document.createElement("<iframe name='" + ajaxframeid + "' id='" + ajaxframeid + "'></iframe>");
		} else {
			ajaxframe = document.createElement("iframe");
			ajaxframe.name = ajaxframeid;
			ajaxframe.id = ajaxframeid;
		}
		//document.body.offsetWidth
		ajaxframe.style.position = 'absolute';
		ajaxframe.style.top = GT($('silverlightControlHost'))+60+"px";
		ajaxframe.style.left = GL($('silverlightControlHost'))+100+"px";
		ajaxframe.style.display = 'block';
		ajaxframe.style.width = '500px';
		ajaxframe.style.height = '400px';
		ajaxframe.style.overflow = "hidden";
		ajaxframe.style.border = '5px solid #2C629E';
		ajaxframe.frameboder = "0";
		ajaxframe.scrolling = "no";
		ajaxframe.src = 'space.php?do=findship&view=getmap';
		$('append_parent').appendChild(ajaxframe);
	}else{
		ajaxframe.style.display = 'block';
	}

}

//获取顶端距离:
function GT(o){
	T=o.offsetTop;
	if(o.offsetParent!=null)
		T+=GT(o.offsetParent);
	return T;
}

//获取左边距离:
function GL(o){
	L =o.offsetLeft;
	if(o.offsetParent!=null)
		L+=GL(o.offsetParent);
	return L;
}
*/